<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>用户登录</title>
		<style type="text/css">
			#show{
				width: 400px;
				margin: 0px auto;
			}
			table{
				text-align: center;
			}
		</style>
		<script src="js/jquery-1.12.4.js"></script>
		<script type="text/javascript">
			$(function(){
				$("form[name=myForm]").submit(function(){
					var bool=Verify();
					return bool;
				});
				$("input[name=username]").blur(function(){
					
					$.get("Register","name="+$(this),callBack);
				});
				
				
			});
			
			function callBack(date){
	     		console.log(date);
	     		var flag=eval(date);
	     		if(flag){
	     			$("#shows").text("此名可用");
	     		}else{
	     			$("#shows").text("此名被占用");
	     		}
			
			function Verify () {
				var bool=true;
				if ($("input[name=username]").val() =="") {
					alert("用户名不能为空");
					bool= false;
				}else if ($("input[name=userpwd]").val() =="") {
					alert("密码不能为空");
					bool= false;
				}else if ($("input[name=userpwd]").val() != $("input[name=pwd1]").val()) {
					alert("密码与确认密码不一致");
					bool= false;
				}else if ($("input[name=name]").val() == "") {
					alert("姓名不能为空");
					bool= false;
				}else if ($("input[name=pwd1]").val() == "") {
					alert("确认密码不能为空");
					bool= false;
				}else if ($("input[name=add]").val() =="") {
					alert("地址不能为空");
					bool= false;
				}else if ($("input[name=phon]").val() =="") {
					alert("电话不能为空");
					bool= false;
				}else if ($("input[name=email]").val() =="") {
					alert("邮箱不能为空");
					bool= false;
				}
				return bool;
			}
		</script>
	</head>
	<body>
		<div id="show">
			<h4>用户注册</h4>
			<form action="AddUser" method="post" name="myForm">	
				<table border="0" cellspacing="" cellpadding="">
					<tr>
						<td>用户名:</td>
						<td>
							<input type="text" name="username" value=""/>
						</td>
					</tr>
					<tr>
						<td>密码:</td>
						<td>
							<input type="text" name="userpwd" value=""/>
						</td>
					</tr>
					<tr>
						<td>密码确认:</td>
						<td>
							<input type="text" name="pwd1" value=""/>
						</td>
					</tr>
					<tr>
						<td>姓名:</td>
						<td>
							<input type="text" name="name" value=""/>
						</td>
					</tr>
					<tr>
						<td>地址:</td>
						<td>
							<input type="text" name="add" value=""/>
						</td>
					</tr>
					<tr>
						<td>电话:</td>
						<td>
							<input type="text" name="phon" value=""/>
						</td>
					</tr>
					<tr>
						<td>Email:</td>
						<td>
							<input type="password" name="email" value=""/>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<input type="submit" name="su" id="su" value="注册" />
						</td>
					</tr>
					<tr>
						<td colspan="2" id="shows" style="text-align: center;color: red;">
							${message }
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>
